import {createStore} from 'vuex'
import VuexPersistence from 'vuex-persist'

// 自动保存vuex数据
const baocunshuju = new VuexPersistence({
    storage: window.sessionStorage
})


// vite版自动导入vuex
let modules = {}
const modulesFiles = import.meta.globEager('./modules/*.js')

const modulesnames = Object.keys(modulesFiles)
modulesnames.forEach(item => {
    const modulesname = item.replace(/(.*\/)*([^.]+).*/gi, '$2')
    modules = {...modules, [modulesname]: modulesFiles[item].default}
})

const store = createStore({
    modules,
    // plugins: [baocunshuju.plugin],
})
console.log(modules,"vuex")
export default store
